package com.zjj.day0425.date;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
class Student {
    String name;
    String studentId;
    LocalDate birthDate;

    public Student(String name, String studentId, LocalDate birthDate) {
        this.name = name;
        this.studentId = studentId;
        this.birthDate = birthDate;
    }

    @Override
    public String toString() {
        return "姓名: " + name + ", 学号: " + studentId + ", 出生日期: " + birthDate;
    }

    public static void main(String[] args) {
        List<Student> studentList = new ArrayList<>();
        studentList.add(new Student("张三", "001", LocalDate.of(2003, 4, 5)));
        studentList.add(new Student("李四", "002", LocalDate.of(2003, 1, 1)));
        studentList.add(new Student("王五", "003", LocalDate.of(2002, 1, 1)));
        studentList.add(new Student("刘六", "004", LocalDate.of(2004, 1, 1)));
        LocalDate zhangsanBirthDate = null;
        for (Student student : studentList) {
            if ("张三".equals(student.name)) {
                zhangsanBirthDate = student.birthDate;
                break;
            }
        }
        if (zhangsanBirthDate != null) {
            System.out.println("比张三年龄大的同学信息:");
            for (Student student : studentList) {
                if (student.birthDate.isBefore(zhangsanBirthDate)) {
                    System.out.println(student);
                }
            }
        }
    }
}